package com.example.manpower.Controller;

import com.example.manpower.Dto.PositionStats;
import com.example.manpower.Entity.Position;
import com.example.manpower.Server.PositionService;
import com.example.manpower.Util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Position")
public class PositionController {
    @Autowired
    private PositionService positionService;
    //分页查询
    @GetMapping("/selectPage")
    public Result select(PositionStats positionStats) {
        return positionService.select(positionStats);
    }

    //新增职位
    @PostMapping("/add")
    public Result add(@RequestBody Position position) {
        System.out.println(position.getPositionName());
        return positionService.add(position);
    }
    //修改职位
    @PutMapping("/update")
    public Result update(@RequestBody Position position) {
        return positionService.updateOne(position);
    }
    @DeleteMapping("/delete")
    public Result delete(Position position) {
        return positionService.delete(position);
    }

    @GetMapping("/select")
    public Result select(Position position) {
        return positionService.selectall(position);
    }
}
